/*****************************************************************************/
/** \file mc_pmsm.h
**
** 
**
** History:
** 
*****************************************************************************/
#ifndef  __MC_PMSM_H__
#define  __MC_PMSM_H__

#include "interface.h"

#define  s8   signed char
#define  s16  signed short int
#define	 s32  signed int 
#define	 u8   unsigned char 
#define	 u16  unsigned short int 
#define	 u32  unsigned int 
	
	
typedef struct
{
	s32 Ia;
	s32 Ib;
	s32 Ic;
}Curr_Components;



typedef struct
{
	s32 Alpha;
	s32 Beta;
}Clarke_Components;

typedef struct
{
	s32 Id;
	s32 Iq;
}Park_Components;

typedef struct
{
	s32 Alpha;
	s32 Beta;
}RevPark_Components;

typedef struct
{
	s32 Cos;
	s32 Sin;
}SinCos_Components;

typedef struct 
{
	s32 Ud;
	s32 Uq;
}Volt_DQ_Components;

typedef struct
{
	s32 Angel;
}ArcTan_Components;

typedef struct
{
	s32 Tu;
	s32 Tv;
	s32 Tw;
	s32 T1;
	s32 T2;
	u8  Sector;
}SVM_Components;

typedef struct 
{
	s32 RampInc;
	s32 RampDec;
	s32 RampTarget;
	s32 RampOut;
	s32 RampBack;
	s32 RampRef;
}Ramp_Components;

extern Curr_Components		  	s_Curr_Phase;
extern SinCos_Components	  	s_SinCos_Val;
extern Clarke_Components	  	s_Curr_alfa_beta;
extern Park_Components		  	s_Curr_d_q;
extern Park_Components		  	s_Curr_d_q_ref;
extern RevPark_Components	  	s_Volt_alfa_beta;
extern Volt_DQ_Components	  	s_Volt_d_q;
extern ArcTan_Components      	s_ArcTan_Compt;  
extern SVM_Components         	s_SVM_CALC;
extern Ramp_Components			s_SpeedCtrl;


extern SinCos_Components  		SinCos_Cal(s32 Angel);
extern Clarke_Components 		Clarke(Curr_Components Iphase);
extern Park_Components 			Park(SinCos_Components SinCosVal, Clarke_Components Clarke);
extern RevPark_Components 		RevPark(SinCos_Components SinCosVal, Volt_DQ_Components Volt);
extern ArcTan_Components 		ArcTan_Cal(s32 hSin, s32 hCos);
extern void 					SVPWM_CALC(SVM_Components *SVM_Compt, RevPark_Components  Volt_alfa_beta);
extern void  					f_MC_SinCosCal(SinCos_Components  *p_SinCosRegS ,  s32 l_angel);
extern void 					MC_Ramp_Control(Ramp_Components *Ramp, s32 Ref);

#endif	/* __MC_PMSM_H__ */
